<?php

namespace Modules\Shop\Http\Controllers;

use Illuminate\Http\Request;
use Illuminate\Http\Response;
use Illuminate\Routing\Controller;
use Modules\Shop\Entities\Comment;

class CommentController extends Controller
{
    /**
     * Display a listing of the resource.
     * @return Response
     */
    public function index()
    {
        $data = Comment::paginate(10);
        return view('shop::comment.index',compact('data'));
    }
    /**
     * Update the specified resource in storage.
     * @param  Request $request
     * @return Response
     */
    public function update(Comment $comment)
    {
        //dd($comment->all());
        //将对应评论状态改为1
        $comment->status = 1;
        $comment->save();
        session()->flash('success','留言内容已通过审核！');
        return back();
    }
    /**
     * Update the specified resource in storage.
     * @param  Request $request
     * @return Response
     */
    public function todel(Comment $comment)
    {
        //dd($comment->all());
        //将对应评论状态改为1
        $comment->status = 0;
        $comment->save();
        session()->flash('success','留言内容未通过！');
        return back();
    }

    /**
     * Remove the specified resource from storage.
     * @return Response
     */
    public function destroy(Comment $comment)
    {
        //将对应评论内容删除
        $comment->delete();
        session()->flash('success','留言删除成功！');
        return back();
    }
}
